﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using yunbo.Model.SM;
using yunbo.Repositorys.BIWRepositorys;
using yunbo.Repositorys.SMRepositorys;

namespace yunbo.Controllers.SMControllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class WMS_RKXXController : ControllerBase
    {
        WMS_RKXXRepository wMS_RKXXRepository=new WMS_RKXXRepository();
        /// <summary>
        /// 添加
        /// </summary>
        /// <returns></returns>
        [HttpPost("PostWMS_RKXX")]
        public IActionResult PostWMS_RKXX(TJWMS_RKXX tJWMS_RKXX)
        {
            // 获取当前时间，并格式化为字符串
            string currentTime = DateTime.Now.ToString("yyyyMMdd");

            // 生成一个四位随机数
            Random random = new Random();
            int randomNumber = random.Next(1000, 10000); // 生成1000到9999之间的随机数
            string randomNumberString = randomNumber.ToString("D4"); // 格式化为四位数字字符串

            // 组合当前时间和随机数生成ID
            string id = $"rkxx{currentTime}{randomNumberString}";
            tJWMS_RKXX.rkxx_code = id;
            bool rs = wMS_RKXXRepository.PostWMS_RKXX(tJWMS_RKXX) > 0;
            return Ok(rs);
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <returns></returns>
        [HttpGet("GetWMS_RKXX")]
        public IActionResult GetWMS_RKXX(string code)
        {
            List<WMS_RKXX> wMS_RKXXes = wMS_RKXXRepository.GetWMS_RKXX(code);
            return Ok(wMS_RKXXes);
        }
    }
}
